package com.itheima.controller;

import com.itheima.common.entity.Result;
import com.itheima.pojo.Login;
import com.itheima.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 手机验证码登录
     * @param login
     * @return
     */
    @PostMapping("/member/login")
    public Result login(@RequestBody Login login){
        String msg =loginService.login(login);
        return new Result(true,msg);
    }


    /**
     * 发送验证码
     * @param telephone
     * @return
     */
    @GetMapping("/validatecode/send4Login")
    public Result sendValidateCode(String telephone){
        loginService.sendValidateCode(telephone);
        return new Result(true,"验证码发送成功");
    }

}
